package com.wqtz.chechai.view.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wqtz.chechai.R;
import com.wqtz.chechai.adapter.WQTZPagerAdapter;
import com.wqtz.chechai.base.BaseFragment;
import com.wqtz.chechai.presenter.BasePresent;
import com.wqtz.chechai.view.activities.SearchActivity;
import com.wqtz.chechai.widget.WQTZViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 项目名称： CheChai
 * 创建人 : Liberation
 * 创建时间: 2016/12/12 13:34
 */

public class QuoteFragment extends BaseFragment {


	@BindView(R.id.tabs)
	TabLayout mTabs;
	@BindView(R.id.search_view)
	TextView mSearchView;
	@BindView(R.id.vp_view)
	WQTZViewPager mVpView;
	private List<String> mTitle = new ArrayList<String>();
	private List<BaseFragment> mFragment = new ArrayList<BaseFragment>();


	@Override
	public BasePresent createPresenter() {
		return null;
	}

	@Override
	protected int getContentView() {
		return R.layout.fragment_quote;
	}

	@Override
	protected void init(View view) {
		ButterKnife.bind(this, view);
		//添加顶部标题
		mTitle.add("报价");
		mTitle.add("放款");
		//设置底部下划线长度
		//WidgetUtils.setIndicator(getContext(), mTabs, 11, 11);

		//添加fragment
		mFragment.add(new QuoteFirstPagerFragment());
		mFragment.add(new QuoteSecondPagerFragment());

		//设置数据
		WQTZPagerAdapter adapter = new WQTZPagerAdapter(getFragmentManager(), mTitle, mFragment);
		mVpView.setAdapter(adapter);
		//为TabLayout设置ViewPager
		mTabs.setupWithViewPager(mVpView);
		//使用ViewPager的适配器
		mTabs.setTabsFromPagerAdapter(adapter);
		mVpView.setCurrentItem(0);


	}

	@Override
	protected void loadDatas() {

	}


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// TODO: inflate a fragment view
		View rootView = super.onCreateView(inflater, container, savedInstanceState);
		ButterKnife.bind(this, rootView);
		return rootView;
	}

	@OnClick(R.id.search_view)
	public void onClick() {
		Intent intent = new Intent(getContext(), SearchActivity.class);
		startActivity(intent);
	}
}
